package com.example.demo.common;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-06-11
 * Time: 10:46
 */
@RestControllerAdvice
public class MyExceptionAdvice {

    /**
     * 异常保底策略
     *
     * @param e 异常对象
     * @return 返回异常同意处理 - 不直接错误500
     */
    @ExceptionHandler(Exception.class)
    public AjaxResult doException(Exception e) {
        return AjaxResult.fail(-1, e.getMessage());
    }

}
